//
//  CLMainViewController.m
//  CLTableViewProject
//
//  Created by Charles on 16/5/17.
//  Copyright © 2016年 Charles. All rights reserved.
//

#import "CLMainViewController.h"
#import "CLTableView.h"
@interface CLMainViewController (){
    CLTableView * _tableView;
}

@end

@implementation CLMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"封装TableView";
    self.view.backgroundColor = [UIColor whiteColor];
    _tableView = [[CLTableView alloc]initWithFrame:self.view.bounds];
    _tableView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:_tableView];
    
    [self getData];
}


- (void)getData{
    CLTableSection *section = [[CLTableSection alloc]init];
    for (int i =0; i<10; i++) {
        CLTableItem * item = [[CLTableItem alloc]init];
        item.viewClass = [CLTableViewCell class];
        item.rowHeight = 60;
        item.desc = [NSString stringWithFormat:@"第%zi行",i+1];
        [section.items addObject:item];
    }
    _tableView.dataSource = [[CLTableViewDataSource alloc]init];
    [_tableView.dataSource.sections addObject:section];
    _tableView.tableView.dataSource = _tableView.dataSource;
    [_tableView.tableView reloadData];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
